home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nebula 2
/
Nebula Two.iso
/
SourceCode
/
GameKit
/
gamekit-1
/
HighScoreDistributor.m
< prev
next >
Wrap
Text File
|
1995-06-12
|
1KB
|
35 lines
#import <appkit/appkit.h>
#import <gamekit/gamekit.h>
#import <remote/NXConnection.h>
#import <objc/HashTable.h>
#define name "DAYHighScoreServer"
@implementation HighScoreDistributor
- init
{
[super init];
servers = [[HashTable alloc] initKeyDesc:"*" valueDesc:"@" capacity:0];
return self;
}
- getServerFor:(const char *)gameName
{ // all we do is maintain a hash table that uses the name of the server
// as a key. If the server is in the hash table, we return it. If it
// isn't in the table, then we create a new server and return it.
id newServer, temp;
if ([servers isKey:gameName]) return [servers valueForKey:gameName];
newServer = [[HighScoreServer alloc] initForGame:gameName];
temp = [servers insertKey:gameName value:newServer];
if (temp) { // server existed. Shouldn't get here if that was the case;
// if we _do_ get here, it's a bug in NeXT's HashTable!
fprintf(stderr, "%s: Just blew away the %s server!\n",
name, [temp gameName]);
[[temp save] free];
}
return newServer;
}
@end